<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui" >

	<h:form id="frm1">
		<p:growl id="msgs1" showDetail="true" />
		<p:panel id="contPanel" header="【第一步】订单基本信息录入" style="margin-bottom:5px">
		
			<h:panelGrid columns="3" cellspacing="10">		
				<p:commandButton value="新增订单" icon="ui-icon-plus" 
	           		process="@this" update=":frm1 :frm2 :frmAttach"
                 	actionListener="#{purchMB.onAddOrder}" />	
				<p:commandButton value="保存订单"	icon="ui-icon-check" 
					action="#{purchMB.saveAction}" update=":frm1:msgs1">
				</p:commandButton>	
			</h:panelGrid>
			
			<h:panelGrid columns="10" cellspacing="10" >								
				<p:outputLabel value="订单编号" />
				<p:inputText  value="#{purchMB.io.id}" required="true" requiredMessage="订单编号必须输入"/>
				<p:outputLabel value="下单日期" />
				<p:calendar id="signDate" locale="zh" navigator="true"  value="#{purchMB.io.orderDate}" 
					pattern="yyyy-MM-dd" mask="true"  mode="popup"	showOn="button" popupIconOnly="true"
					required="true" requiredMessage="订单日期必须输入" />

				<p:outputLabel value="合同选择" />
				<p:selectOneMenu value="#{purchMB.selectedContract}" converter="bmeContractConverter" 
						effect="fade"  style="width:80%" panelStyle="width:180px" 
                        var="t" filter="true" filterMatchMode="startsWith"
                        required="true" requiredMessage="合同名称必须输入" 
                        converterMessage="合同信息不能正确转换">
                    <p:ajax listener="#{purchMB.onSelectedContract}" update=":frm1:pcontract :frm1:pproject :frm1:paddress :frm1:psupplierid :frm1:psupplier :frm2:purchBtnPanel" />  
                    <f:selectItem itemLabel="选择..." itemValue="" noSelectionOption="true"  />   
		            <f:selectItems value="#{purchMB.bmeContracts}" var="scontrtacr" itemLabel="#{scontrtacr.id}" itemValue="#{scontrtacr}" />
		 
		            <p:column style="width:10%">
		                <h:outputText value="#{t.id}" />
		            </p:column>		 
		            <p:column>
		                <h:outputText value="#{t.name}" />
		            </p:column>        
		        </p:selectOneMenu>
				<p:outputLabel value="合同名称" />
				<p:inputText id="pcontract" value="#{purchMB.selectedContract.name}"  readonly="true"  disabled="true"/>
				<p:outputLabel value="项目名称" />
				<p:inputText id="pproject" value="#{purchMB.selectedContract.pname}"  readonly="true"  disabled="true"/>
				
				<p:outputLabel value="供应商选择" />
				<p:selectOneMenu id="psupplierid" value="#{purchMB.selectedSupplier}" converter="bmeSupplierConverter" 
						effect="fade"  style="width:80%" panelStyle="width:180px" 
                        var="t" filter="true" filterMatchMode="startsWith"
                        required="true" requiredMessage="供应商ID必须输入" >
                    <p:ajax update=":frm1:psupplier " />     
                    <f:selectItem itemLabel="选择..." itemValue="" noSelectionOption="true"  />
		            <f:selectItems value="#{purchMB.bmeSuppliers}" var="ssupplier" itemLabel="#{ssupplier.id}" itemValue="#{ssupplier}" />
		 
		            <p:column style="width:10%">
		                <h:outputText value="#{t.id}" />
		            </p:column>		 
		            <p:column>
		                <h:outputText value="#{t.name}" />
		            </p:column>        
		        </p:selectOneMenu>
        
				<p:outputLabel value="供应商名称" />
				<p:inputText id="psupplier" value="#{purchMB.selectedSupplier.name}"  disabled="true"/>

				<p:outputLabel value="收货地址" />
				<p:inputText id="paddress" value="#{purchMB.io.shippingAddress}" />	
				<p:outputLabel value="收货人" />
				<p:inputText value="#{purchMB.io.consignee}" />	
				<p:outputLabel value="电话" />
				<p:inputText value="#{purchMB.io.phone}" />	
				
				<p:outputLabel value="订单状态" />
				<p:selectOneMenu value="#{purchMB.io.status}" effect="fold" style="width:80%;" 
					required="true" requiredMessage="状态必须输入" >
					<f:selectItem itemLabel="选择..." itemValue="" noSelectionOption="true"  />
					<f:selectItems value="#{purchMB.itemsPurchStatus}" />
				</p:selectOneMenu>					
				<p:outputLabel value="备注" />
				<p:inputText value="#{purchMB.io.remarks}" />	
				<p:outputLabel value="订单金额" />
				<p:inputText id="pOrderAmount" value="#{purchMB.io.amount}"  disabled="true"/>	
									
			</h:panelGrid>
				
		</p:panel>
		
	</h:form>

	<h:form id="frmAttach" > 	
		<p:growl id="msgsAttach" showDetail="true" />		
		<p:panel header="附件信息上传" toggleable="true" toggleSpeed="500" 
			 style="margin-bottom:10px" collapsed="true">
			<p:ajax event="toggle" listener="#{attachUploadMB.onToggle}" update="frmAttach" /> 
			<!-- 页面间参数传递 -->
			<ui:include src="bme_attach_upload.xhtml">
			     <ui:param name="uploadForType" value="#{purchMB.uploadForType}" />
			     <ui:param name="uploadForId" value="#{purchMB.uploadForId}" />
			     <ui:param name="uploadForName" value="#{purchMB.uploadForName}" />
			</ui:include>
        </p:panel>
	</h:form>	
</ui:composition>
